package com.ss.android.newmedia;

import android.app.Application;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.telephony.TelephonyManager;

import com.ss.android.common.AppContext;
import com.ss.android.common.app.AppHooks;
import com.ss.android.gallery.comic.R;

public abstract class NewMediaApplication extends Application
	implements AppContext,AppHooks.InitHook{
	protected final String mAppName;
	protected String mChannel="local";
	protected String mDeviceId;
	protected final String mFeedbackKey;
	protected final String mSdkAppId;
	protected int mVersionCode=-1;
	protected String mVersionName;
	
	protected NewMediaApplication(String appName,String sdkAppId,String feedbackKey){
		this.mAppName=appName;
		this.mSdkAppId=sdkAppId;
		this.mFeedbackKey=feedbackKey;
	}
	
	//protected abstract BaseAppData getAppData();
	
	public String getAppName(){
		return this.mAppName;
	}
	
	public String getChannel(){
		return this.mChannel;
	}
	
	public Context getContext(){
		return this;
	}
	
	public String getDeviceId(){
		return this.mDeviceId;
	}
	
	public String getFeedbackAppKey(){
		return this.mFeedbackKey;
	}
	
	public String getStringAppName(){
		return getString(R.string.app_name);
	}
	
	public String getVersion(){
		return this.mVersionName;
	}
	
	public int getVersionCode(){
		return this.mVersionCode;
	}
	
	public void onCreate(){
		super.onCreate();
		try{
			this.mDeviceId=((TelephonyManager)getSystemService("phone")).getDeviceId();
			this.mVersionName=getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
			PackageInfo packageInfo=getPackageManager().getPackageInfo(getPackageName(), 0);
			if(packageInfo!=null){
				this.mVersionCode=packageInfo.versionCode;
			}
			if(this.mDeviceId==null){
				this.mDeviceId="";
			}
			if(this.mVersionName==null){
				this.mVersionName="-1";
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public void tryInit(Context context){
		//BaseAppData.inst().tryInit(context);
	}
}
